<div id='complain_list'>
	<h3>申诉记录:</h3>
	<div id='complain_info_list'>
		<!--div style='font-size:12px;border-bottom:1px solid #ccc;padding-bottom:10px'>
			<div>申诉车牌：吉EEJ322</div>
			<div>申诉详情：详情详情详情详情详情详情详情详情详情详情详情</div>
			<div>申诉时间：2018-07-28 20:22:17</div>
			<div>申诉状态：已完成</div>
			<div>处理结果：车牌以解除绑定，请自行重新绑定！</div>
		</div-->
	</div>
</div>




<!-- 申诉区 -->
<div id='complain_submit_area' style='margin:10px 0;display:none'>
	<div style='display:flex'>
		<div style='width:85px'>申诉车牌：</div>
		<div style='flex:1'><input type="text" id='complain_number'></div>
	</div>

	<div style='display:flex;margin:20px 0'>
		<div style='width:85px'>申诉详情：</div>
		<div style='flex:1'>
			<textarea id='complain_info' style='width:100%;height:100px;resize:none'></textarea>
		</div>
	</div>

	<div>
		车辆正照：<input type="file" id='complain_img1'/> 
		<div style='text-align:right'>
			<span id='complain_img1_span'>示例：</span>
			<img id='complain_img1_view' src="Public/car1.jpg" width='50%' alt="">
		</div>
	</div>
	<div style='margin:20px 0'>
		行驶证照：<input type="file" id='complain_img2'/>	
		<div style='text-align:right'>
			<span id='complain_img2_span'>示例：</span>
			<img id='complain_img2_view' src="Public/car2.jpg" width='50%' alt="">
		</div>
	</div>
	<div style='text-align:center;margin:50px 0'>
		<button id='complain_submit_area_submit'>提交</button>
		<button id='complain_submit_area_back'>返回</button>
	</div>
</div>
<div style="text-align:center;margin:20px" id="fpage"> </div>

<div style='text-align:center;margin:50px 0'><button id='complain_view_area'>我要申诉</button></div>



<script>
if(!sessionStorage.complian_pnow){
	sessionStorage.complian_pnow = 1;
}

Complain_Get_Info_List();

//获取申诉列表
function Complain_Get_Info_List(){
	var complain_sess_name = 'sessionStorage.complain_info_list_'+sessionStorage.complian_pnow;
	if(eval(complain_sess_name)){
		C('complain_sess');
		Complain_Parse_Info(eval(complain_sess_name));	//解析数据
	}else{		
		var cache_path = 'Cache/Complain/'+GetCookie('openid')+sessionStorage.complian_pnow;
		Ajax({},function(res_cache){
			if(res_cache == 'false'){	
				var type='complain_get_info_list';	//后台加载数据
				Get_Token(type,function(t){
					var data = {
						token:t,
						type:type,
						pnow:sessionStorage.complian_pnow
					};
					Ajax(data,function(res){
						C('complain_after');
						var complain_sess_name2 = complain_sess_name+"='"+res+"'";
						eval(complain_sess_name2);
						//sessionStorage.complain_info_list_sess = res;
						Complain_Parse_Info(res);	
					});
				});
			}else{
				C('complain_cache');
				//sessionStorage.complain_info_list_sess = res_cache;
				var complain_sess_name2 = complain_sess_name+"='"+res_cache+"'";
				eval(complain_sess_name2);
				Complain_Parse_Info(res_cache);	//解析数据
			}
		},cache_path);
	}


}





var complain_file = new Object();	//装载图片变量
//我要申诉
$('#complain_view_area').click(function(){
	$('#complain_submit_area').show();
	$('#complain_view_area').hide();
	$('#complain_list').hide();
});

//返回
$('#complain_submit_area_back').click(function(){
	$('#complain_submit_area').hide();
	$('#complain_view_area').show();
	$('#complain_list').show();
});


//图片1上传并显示 
complain_img1.onchange=function(){
  	complain_file.img1 = complain_img1.files[0];
  	if(CheckFile(complain_file.img1) == true){
		var reader = new FileReader();
		reader.onloadend = function(){
			complain_img1_view.src = reader.result;
			complain_img1_span.style.display='none';
		}
		if(complain_file.img1){
			reader.readAsDataURL(complain_file.img1);
		}else{
			complain_img1_view.src='';
		}
	}else{
		A('图片大小超限或格式不正确!');
		complain_file.img1=null;
		complain_img1_view.src='';
		complain_img1_span.style.display='none';
	}
}


//图片2上传并显示 
complain_img2.onchange=function(){
  complain_file.img2 = complain_img2.files[0];
  	if(CheckFile(complain_file.img2) == true){
		var reader = new FileReader();
		reader.onloadend = function(){
			complain_img2_view.src = reader.result;
			complain_img2_span.style.display='none';
		}
		if(complain_file.img2){
			reader.readAsDataURL(complain_file.img2);
		}else{
			complain_img2_view.src='';
		}
	}else{
		A('图片大小超限或格式不正确!');
		complain_file.img2=null;
		complain_img2_view.src='';
		complain_img2_span.style.display='none';
	}
}




//点击提交 
$('#complain_submit_area_submit').click(function(){


	var complain_number = $('#complain_number').val().trim();
	Check_Car_Number(complain_number);
	var complain_info = ChangeChar($('#complain_info').val().trim());
	if(!complain_info){
		A('申诉详情不得为空!');return;
	}
	if(complain_file.img1 == undefined){
		A('缺少车辆正照!');return;
	}
	if(complain_file.img2 == undefined){
		A('缺少行驶证照!');return;
	}
	notice('申请提交中......');
	var type='complain_submit';
	Get_Token(type,function(t){
		var formData = new FormData();
		formData.append('img1',complain_file.img1); //添加文件
		formData.append('img2',complain_file.img2); //添加文件
		formData.append('number',complain_number); //添加信息
		formData.append('info',complain_info); //添加信息
		formData.append('type',type); //添加信息
		formData.append('token',t); //添加信息
		AjaxSendFile(formData,main_url,'POST',function(res){
			if(res == 'ok'){
				sessionStorage.complian_pnow = 1;	//重置当前页
				for(var i in sessionStorage){		//清空sess缓存
					if(/^complain_info_list_/.test(i)){
						sessionStorage.removeItem(i);
					}
				}
				alert('申诉提交成功!');
				$('#complain_submit_area').hide();
				$('#complain_view_area').show();
				$('#complain_list').show();
				Complain_Get_Info_List();
			}else if(res == 'err2'){
				alert('车牌申诉正在处理中,不要重复申诉!');
			}else{
				alert('操作异常!');
			}
			notice('');	
		});
	});
});










//解析申诉列表数据
function Complain_Parse_Info(res){
	if(!/^{.*}$/.test(res)){
		return;
	}
	var info = JSON.parse(res);
	var data = info.data;
	if(!data){
		return;
	}
	var complain_info_list_str = '';
	for(var i=0;i<data.length;i++){
		var time = parseInt(data[i].ctime) * 1000;
		time = StampToYmd(time,1);
		complain_info_list_str += "<div style='font-size:12px;border-bottom:1px solid #ccc;padding-bottom:10px'>";
		complain_info_list_str += "<div>申诉车牌："+data[i].number+"</div>";
		complain_info_list_str += "<div style='word-break:break-all'>申诉详情："+data[i].info+"</div>";
		complain_info_list_str += "<div>申诉时间："+time+"</div>";
		complain_info_list_str += "<div>申诉状态："+(data[i].stat==1?'处理中':'已完成')+"</div>";
		if(data[i].backinfo){
			complain_info_list_str += "<div>处理结果："+data[i].backinfo+"</div>";
		}
		complain_info_list_str += "</div>";
	}
	$('#complain_info_list').html(complain_info_list_str);
	Fpage4(info.pnow,info.max_page,function(pnow){
		sessionStorage.complian_pnow = pnow;
		Complain_Get_Info_List();
	},60,3); //>>连续后翻60页，当前页前后各显示3页
}

</script>







